Initial revision
authorØyvind Kolås <ok@src.gnome.org>
Tue, 9 Aug 2005 13:18:52 +0000 (13:18 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Tue, 9 Aug 2005 13:18:52 +0000 (13:18 +0000)
54 files changed:
.cvsignore [new file with mode: 0644]
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
INSTALL.in [new file with mode: 0644]
Makefile-mini [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
NEWS [new file with mode: 0644]
README.in [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
babl.pc.in [new file with mode: 0644]
babl/.cvsignore [new file with mode: 0644]
babl/Makefile-mini [new file with mode: 0644]
babl/Makefile.am [new file with mode: 0644]
babl/babl-classes.c [new file with mode: 0644]
babl/babl-classes.h [new file with mode: 0644]
babl/babl-component.c [new file with mode: 0644]
babl/babl-component.h [new file with mode: 0644]
babl/babl-conversion.c [new file with mode: 0644]
babl/babl-conversion.h [new file with mode: 0644]
babl/babl-db.h [new file with mode: 0644]
babl/babl-fish.c [new file with mode: 0644]
babl/babl-fish.h [new file with mode: 0644]
babl/babl-format.c [new file with mode: 0644]
babl/babl-format.h [new file with mode: 0644]
babl/babl-ids.h [new file with mode: 0644]
babl/babl-internal.c [new file with mode: 0644]
babl/babl-internal.h [new file with mode: 0644]
babl/babl-introspect.c [new file with mode: 0644]
babl/babl-introspect.h [new file with mode: 0644]
babl/babl-memory.c [new file with mode: 0644]
babl/babl-memory.h [new file with mode: 0644]
babl/babl-model.c [new file with mode: 0644]
babl/babl-model.h [new file with mode: 0644]
babl/babl-pixel-format.c [new file with mode: 0644]
babl/babl-pixel-format.h [new file with mode: 0644]
babl/babl-sampling.c [new file with mode: 0644]
babl/babl-sampling.h [new file with mode: 0644]
babl/babl-sanity.c [new file with mode: 0644]
babl/babl-sanity.h [new file with mode: 0644]
babl/babl-type.c [new file with mode: 0644]
babl/babl-type.h [new file with mode: 0644]
babl/babl-util.c [new file with mode: 0644]
babl/babl-util.h [new file with mode: 0644]
babl/babl.c [new file with mode: 0644]
babl/babl.h [new file with mode: 0644]
configure.ac [new file with mode: 0644]
depcomp [new file with mode: 0755]
install-sh [new file with mode: 0755]
missing [new file with mode: 0755]
tests/.cvsignore [new file with mode: 0644]
tests/Makefile.am [new file with mode: 0644]
tests/introspect.c [new file with mode: 0644]
tests/nop.c [new file with mode: 0644]

diff --git a/.cvsignore b/.cvsignore
new file mode 100644 (file)
index 0000000..7dbc840
--- /dev/null
@@ -0,0 +1,19 @@
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+babl.pc
+config.cache
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+libtool
+ltmain.sh
+stamp-h
+stamp-h1
+stamp-h.in
+
diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..5358c95
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Øyvind Kolås
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..bf50f20
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,482 @@
+                 GNU LIBRARY GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+                   59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL.  It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it.  You can use it for
+your libraries, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library.  If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+\f
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software.  To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+  Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs.  This
+license, the GNU Library General Public License, applies to certain
+designated libraries.  This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+  The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it.  Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program.  However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+  Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries.  We
+concluded that weaker conditions might promote sharing better.
+
+  However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves.  This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them.  (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.)  The hope is that this
+will lead to faster development of free libraries.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+  Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+\f
+                 GNU LIBRARY GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License").  Each licensee is
+addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    c) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    d) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the 
+    Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
+    Boston, MA  02111-1307  USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..3563634
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,34 @@
+2005-08-09  Øyvind Kolås  <pippin@gimp.org>
+
+       Imported into GNOME CVS.
+
+2005-08-09  Øyvind Kolås  <pippin@gimp.org>
+
+       - seperate babl-base into separate subdir.
+
+2005-08-09  Øyvind Kolås  <pippin@gimp.org>
+
+       - Renamed class to model.
+       - Auto toolification
+
+2005-08-08  Øyvind Kolås  <pippin@gimp.org>
+
+       - Completed data model
+       - Added sanity checker
+
+2005-08-07  Øyvind Kolås  <pippin@gimp.org>
+
+       - Introspection
+
+2005-08-05  Øyvind Kolås  <pippin@gimp.org>
+
+       - Initial ChangeLog
+
+2005-07-31  Øyvind Kolås  <pippin@gimp.org>
+
+       - Type system
+
+2005-07-29  Øyvind Kolås  <pippin@gimp.org>
+
+       - Babl's inception in the 'Chaos Village' at WhatTheHack.
+
diff --git a/INSTALL.in b/INSTALL.in
new file mode 100644 (file)
index 0000000..59aef8d
--- /dev/null
@@ -0,0 +1,21 @@
+
+Babl @BABL_VERSION@
+
+    Dynamic; any to any, pixel format conversion library.
+
+-----------------------------------------------------------------------
+
+Installation instructions:
+--------------------------
+
+From a released version the following is the expected method of
+installation (or a variation on this theme):
+
+     ------------------------------------------------------------
+     foo$ wget http://pippin.gimp.org/babl/files/old/babl-@BABL_VERSION@.tar.gz
+     foo$ tar xzf babl-@BABL_VERSION@.tar.gz
+     foo$ cd babl-@BABL_VERSION@
+     foo/babl-@BABL_VERSION@$ ./configure && make && sudo make install
+     ------------------------------------------------------------
+
+
diff --git a/Makefile-mini b/Makefile-mini
new file mode 100644 (file)
index 0000000..72b3abf
--- /dev/null
@@ -0,0 +1,11 @@
+# Minimal makefile to test that babl compiles, and for running
+# introspection/sanity tests, will not build an actual library
+
+all:
+       make -f Makefile-mini -C babl ../tests/nop
+       tests/nop
+introspect:
+       make -f Makefile-mini -C babl ../tests/introspect
+       tests/introspect
+clean:
+       make -f Makefile-mini -C babl clean
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..22f57a3
--- /dev/null
@@ -0,0 +1,31 @@
+AUTOMAKE_OPTIONS = foreign
+
+SUBDIRS=       babl    \
+              tests
+
+
+DIST_SUBDIRS = babl    \
+              tests
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = babl.pc
+
+EXTRA_DIST =           \
+       .cvsignore      \
+       COPYING         \
+       ChangeLog       \
+       README.in       \
+       INSTALL.in      \
+       NEWS            \
+       babl.pc.in      \
+       autogen.sh      \
+       Makefile-mini
+
+BUILT_EXTRA_DIST =     \
+       README          \
+       babl.pc
+
+.PHONY: snapshot
+
+snapshot:
+       $(MAKE) dist distdir=$(PACKAGE)-`date +"%Y%m%d"`
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..564b4a5
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,5 @@
+babl-0.0.1:
+
+Initial public release of babl, minimal working configuration for
+RGB, CMYK and YCbCr for 8bit 16bit float and double. Emphasis is on
+precision and clarity of code not speed.
diff --git a/README.in b/README.in
new file mode 100644 (file)
index 0000000..1ab3231
--- /dev/null
+++ b/README.in
@@ -0,0 +1,130 @@
+
+Babl @BABL_VERSION@
+
+    Dynamic; any to any, pixel format conversion library.
+
+-----------------------------------------------------------------------
+
+
+General Information
+===================
+
+This is babl version @BABL_VERSION@, babl is a pixel format conversion
+library the provides conversions to and from any formats.
+
+The official web site is:
+    http://pippin.gimp.org/babl/
+
+
+Installation
+============
+
+See the file 'INSTALL'
+
+
+Current features
+================
+
+Bootstrapping with a reference conversions (to be used later for
+regression tests during development of optimized versions.)
+
+Data types (using "double" as common translation type): 
+
+        "u8"       unsigned 8bit 
+        "u16"      unsigned 16bit
+        "float"    32bit floating point
+        "double"   64bit floating point
+
+Color models (using "rgba" as common translation type):
+
+        "rgb"      color
+        "rgba"     color+alpha
+        "rgbA"     color with premultiplied alpha
+        "srgb"     Gamma corrected "rgb"
+        "srgba"    Gamma corrected "rgb" with linear alpha
+        "g"        grayscale
+        "ga"       grayscale+alpha
+        "gA"       grayscale with premultiplied alpha
+        "ycbcr"    Luminance and chrominances (common in video world)
+        "ycbcra"   Luminance chromninances and alpha.
+
+Sampling factors:
+
+        (1,1)      Full sampling
+        (2,1)      Half horizontal sampling
+        (2,1)      Quartersize horizontal sampling
+        (1,2)      Half vertical sampling
+        (2,2)      Half resolution sampling
+        (4,4)      Quartersize sampling
+
+        The sampling factors can be used to implement chroma subsampling:
+
+        YCbCr      Y     Cb    Cr
+        --------+-------------------
+        4:4:4      (1,1) (1,1) (1,1)
+        4:2:2      (1,1) (2,1) (2,1)
+        4:1:1      (1,1) (4,1) (4,1)
+        4:2:0      (1,1) (2,2) (2,2)
+       
+Pixel Formats:
+
+        (Any format allowed by the models and types can be specified,
+         the following are named for easy reference.)
+
+        "srgb"          8bit gamma corrected image with linear alpha
+        "srgba"         used for instance for PNG files.
+        
+        "rgb_float"     Floating point buffer, good choice for
+        "rgba_float"    prototyping image processing code before
+                        optimizing using other pixel formats.
+        
+        "lab_float"     A representation useful for calculations that
+        "laba_float"    prefers to work in a perceptually uniform color
+                        space (note that lab is not perceptually
+                        uniform, but closer than most others, /CIE lab/
+                        is used extensively in color science, and many
+                        approaches to color difference are based in
+                        this color model.)
+
+        "yuv420"        Video based format, often used with codecs for
+                        instance communicating with libavcodec from the
+                        ffmpeg project.
+
+        "cmyk_float"    A floating point cmyk buffer based directly on
+        "cmyka_float"   linear RGB.
+
+                         cyan    =  (1.0-r) - min(1.0-r, 1.0-g, 1.0-b)
+                         yellow  =  (1.0-r) - min(1.0-r, 1.0-g, 1.0-b)
+                         magenta =  (1.0-r) - min(1.0-r, 1.0-g, 1.0-b)
+
+
+Introspection
+=============
+
+Dumpig of the babl's internal state for debugging purposes.
+
+
+Sanity checking
+===============
+
+Babl will complain verbosely if any of the registered data types or
+color models do not have sufficient reference conversions to be
+regression tested properly.
+
+
+Planned features
+================
+
+- Regression testing against double based reference implementation for
+  development of optimized conversions.
+
+- Dynamically loaded modules with additional color models, data types,
+  pixel formats and conversions.
+
+- Compile time, and maybe runtime, profiling of conversions.
+
+- Conversion auto builder (BablFish) capable of finding the fastest path
+  through the set of registered conversions to perform a specified
+  conversion without precision loss.
+
+
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..4db3def
--- /dev/null
@@ -0,0 +1,48 @@
+#! /bin/sh
+
+# $Id$
+#
+# Copyright (c) 2002  Daniel Elstner  <daniel.elstner@gmx.net>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License VERSION 2 as
+# published by the Free Software Foundation.  You are not allowed to
+# use any other version of the license; unless you got the explicit
+# permission from the author to do so.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+dir=`echo "$0" | sed 's,[^/]*$,,'`
+test "x${dir}" = "x" && dir='.'
+
+if test "x`cd "${dir}" 2>/dev/null && pwd`" != "x`pwd`"
+then
+    echo "This script must be executed directly from the source directory."
+    exit 1
+fi
+
+rm -f config.cache acconfig.h
+
+echo "- libtoolize."           && \
+libtoolize --force             && \
+echo "- aclocal."              && \
+aclocal                                && \
+echo "- autoconf."             && \
+autoconf                       && \
+echo "- autoheader."           && \
+autoheader                     && \
+echo "- automake."             && \
+automake --add-missing --gnu   && \
+echo                           && \
+./configure "$@"               && exit 0
+
+exit 1
+
diff --git a/babl.pc.in b/babl.pc.in
new file mode 100644 (file)
index 0000000..8635189
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: babl
+Description: Dynamic; any to any, pixel format conversion library
+Version: @VERSION@
+Libs: -L${libdir} -lbabl
+Cflags: -I${includedir}/babl
+
diff --git a/babl/.cvsignore b/babl/.cvsignore
new file mode 100644 (file)
index 0000000..ac46a4b
--- /dev/null
@@ -0,0 +1,6 @@
+Makefile
+Makefile.in
+.deps
+*.lo
+*.la
+.libs
diff --git a/babl/Makefile-mini b/babl/Makefile-mini
new file mode 100644 (file)
index 0000000..296f525
--- /dev/null
@@ -0,0 +1,44 @@
+# This makeile is used for more rapid test compilations than
+# autofoo allows, it will not build a usable libray though.
+
+default: clean all
+
+TARGETS =                              \
+       ../tests/nop                    \
+       ../tests/introspect
+
+CFLAGS = -Wall -g -O1 -I./babl-base  -I. -I..
+
+BABL_OBJECTS=                                  \
+       babl.o                                  \
+       babl-base/babl-base.o                   \
+       babl-base/babl-base-types.o             \
+       babl-base/babl-base-components.o        \
+       babl-base/babl-base-conversions.o       \
+       babl-base/babl-base-conversions-type.o  \
+       babl-base/babl-base-conversions-model.o \
+       babl-base/babl-base-models.o            \
+       babl-base/babl-base-pixel-formats.o     \
+       babl-classes.o                          \
+       babl-component.o                        \
+       babl-conversion.o                       \
+       babl-fish.o                             \
+       babl-introspect.o                       \
+       babl-memory.o                           \
+       babl-model.o                            \
+       babl-pixel-format.o                     \
+       babl-sampling.o                         \
+       babl-sanity.o                           \
+       babl-type.o                             \
+       babl-util.o                             \
+
+
+../tests/nop: ../tests/nop.c $(BABL_OBJECTS)
+       gcc -o $@ $< $(BABL_OBJECTS) -I../babl/
+
+../tests/introspect: ../tests/introspect.c $(BABL_OBJECTS)
+       gcc -o $@ $< $(BABL_OBJECTS) -I../babl/
+
+clean:
+       rm -f $(TARGETS) $(BABL_OBJECTS) ../*~ ../*/*~ ../*/*~
+
diff --git a/babl/Makefile.am b/babl/Makefile.am
new file mode 100644 (file)
index 0000000..9337725
--- /dev/null
@@ -0,0 +1,64 @@
+## Source directory
+
+SUBDIRS = babl-base
+
+c_sources =                            \
+        babl.c                         \
+       babl-classes.c                  \
+       babl-component.c                \
+       babl-conversion.c               \
+       babl-fish.c                     \
+       babl-introspect.c               \
+       babl-memory.c                   \
+       babl-model.c                    \
+       babl-pixel-format.c             \
+       babl-sampling.c                 \
+       babl-sanity.c                   \
+       babl-type.c                     \
+       babl-util.c
+
+h_sources  =                           \
+       babl-classes.h                  \
+       babl-component.h                \
+       babl-conversion.h               \
+       babl-db.h                       \
+       babl-ids.h                      \
+       babl-internal.h                 \
+       babl-introspect.h               \
+       babl-fish.h                     \
+       babl-memory.h                   \
+       babl-model.h                    \
+       babl-pixel-format.h             \
+       babl-sampling.h                 \
+       babl-sanity.h                   \
+       babl-type.h                     \
+       babl-util.h                     \
+       babl.h
+
+library_includedir=$(includedir)/babl-$(BABL_API_VERSION)/babl
+library_include_HEADERS =              \
+       babl.h                          \
+       babl-classes.h                  \
+       babl-component.h                \
+       babl-conversion.h               \
+       babl-fish.h                     \
+       babl-model.h                    \
+       babl-pixel-format.h             \
+       babl-sampling.h                 \
+       babl-type.h
+
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/babl/babl-base
+
+lib_LTLIBRARIES= libbabl.la
+libbabl_la_SOURCES= $(h_sources) $(c_sources)
+libbabl_la_LIBADD=\
+       babl-base/libbabl_base.la
+
+libbabl_la_LDFLAGS= \
+       -version-info $(BABL_LIBRARY_VERSION) \
+       -release $(BABL_RELEASE)
+
+EXTRA_DIST := $(wildcard *.h)  \
+       .cvsignore              \
+       Makefile-mini
+
diff --git a/babl/babl-classes.c b/babl/babl-classes.c
new file mode 100644 (file)
index 0000000..6303c9f
--- /dev/null
@@ -0,0 +1,47 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl-classes.h"
+
+static const char *class_names[] =
+  {
+    "BablInstance",
+    "BablType",
+    "BablSampling",
+    "BablComponent",
+    "BablModel",
+    "BablPixelFormat",
+    "BablConversion",
+    "BablConversionType",
+    "BablConversionTypePlanar",
+    "BablConversionModelPlanar",
+    "BablConversionPixelFormatPlanar",
+    "BablConversionPixelFormatPlanar",
+    "BablFish",
+    "BablCeiling"
+  };
+
+const char *
+babl_class_name (BablClassType klass)
+{
+  return class_names[klass-BABL_INSTANCE];
+}
+
+int babl_hmpf_on_name_lookups = 1;
+
diff --git a/babl/babl-classes.h b/babl/babl-classes.h
new file mode 100644 (file)
index 0000000..29f9ed3
--- /dev/null
@@ -0,0 +1,253 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_CLASSES_H
+#define _BABL_CLASSES_H
+
+#ifdef BABL_SKETCHPAD
+
+BablClassType
+  BablInstance
+    BablType
+    BablSampling
+    BablComponent
+    BablModel
+    BablPixelFormat
+    BablConversion
+      BablConversionType
+      BablConversionTypePlanar
+      BablConversionModelPlanar
+      BablConversionPixelFormat
+      BablConversionPixelFormatPlanar
+
+maybe it could make sense to split model into the following, where
+the current model would live on in the component model,.
+    BablModelType
+    BablModelSampling
+    BablModelComponent
+
+    BablConversionModelType
+    BablConversionModelSampling
+    BablConversionModelComponent
+#endif
+
+/* Type and PixelFormat */
+typedef void (*BablFuncLinear)    (void  *src,
+                                   void  *dst,
+                                   int    n);
+
+/* TypePlanar, ModelPlanar and PixelFormatPlanar */
+typedef void (*BablFuncPlanar)    (int    src_bands,
+                                   void  *src[],
+                                   int    src_pitch[],
+                                   int    dst_bands,
+                                   void  *dst[],
+                                   int    dst_pitch[],
+                                   int    n);
+
+typedef void (*BablFuncPlanarBit) (int    src_bands,
+                                   void  *src[],
+                                   int    src_bit[],
+                                   int    src_pitch[],
+                                   int    src_bit_pitch[],
+                                   int    dst_bands,
+                                   void  *dst[],
+                                   int    dst_bit[],
+                                   int    dst_pitch[],
+                                   int    dst_bit_pitch[],
+                                   int    n);
+
+typedef enum {
+  BABL_INSTANCE = 0xBAB10000,
+  BABL_TYPE,
+  BABL_SAMPLING,
+  BABL_COMPONENT,
+  BABL_MODEL,
+  BABL_PIXEL_FORMAT,
+
+  BABL_CONVERSION,
+  BABL_CONVERSION_TYPE,
+  BABL_CONVERSION_TYPE_PLANAR,
+  BABL_CONVERSION_MODEL_PLANAR,
+  BABL_CONVERSION_PIXEL_FORMAT,
+  BABL_CONVERSION_PIXEL_FORMAT_PLANAR,
+
+  BABL_FISH,
+
+  BABL_SKY
+} BablClassType;
+
+#define BABL_CLASS_TYPE_IS_VALID(klass_type) \
+    (  ((klass_type)>=BABL_INSTANCE ) && ((klass_type)<=BABL_SKY) ?1:0 )
+
+/* common header for any item inserted into database */
+typedef struct
+{
+  BablClassType  type;
+  int            id;      /*< a numerical id, look at 'babl-ids.h' for the reserved
+                              ones */
+  char          *name;    /*< the name this type exists under         */
+} BablInstance;
+
+typedef struct
+{
+  BablInstance           instance;
+  union Babl            *source;
+  union Babl            *destination;
+  int                    time_cost;
+  int                    loss;
+  union
+    {
+      BablFuncLinear     linear;
+      BablFuncPlanar     planar;
+      BablFuncPlanarBit  planar_bit;
+    } function;
+} BablConversion;
+
+typedef struct
+{
+  BablConversion conversion;
+} BablConversionType;
+
+typedef struct
+{
+  BablConversion conversion;
+} BablConversionTypePlanar;
+
+typedef struct
+{
+  BablConversion conversion;
+} BablConversionModelPlanar;
+
+typedef struct
+{
+  BablConversion conversion;
+} BablConversionPixelFormat;
+
+typedef struct
+{
+  BablConversion conversion;
+} BablConversionPixelFormatPlanar;
+
+typedef struct
+{
+  BablInstance     instance;
+  BablConversion **from;  /*< NULL terminated list of conversions from class */
+  BablConversion **to;    /*< NULL terminated list of conversions to class   */
+  int              bits;  /*< number of bits used to represent the data type
+                            (initially restricted to a multiple of 8) */
+} BablType;
+
+typedef struct
+{
+  BablInstance instance;
+  BablConversion **from; /*< NULL terminated list of conversions from class */
+  BablConversion **to;   /*< NULL terminated list of conversions to class   */
+  int          horizontal;
+  int          vertical;
+} BablSampling;
+
+typedef struct
+{
+  BablInstance instance;
+  BablConversion **from; /*< NULL terminated list of conversions from class */
+  BablConversion **to;   /*< NULL terminated list of conversions to class   */
+  int          luma;
+  int          chroma;
+  int          alpha;
+} BablComponent;
+
+
+typedef struct
+{
+  BablInstance     instance;
+  BablConversion **from; /*< NULL terminated list of conversions from class */
+  BablConversion **to;   /*< NULL terminated list of conversions to class   */
+  int              components;
+  BablComponent  **component;
+} BablModel;
+
+typedef struct
+{
+  BablInstance     instance;
+  BablConversion **from; /*< NULL terminated list of conversions from class */
+  BablConversion **to;   /*< NULL terminated list of conversions to class   */
+  int              planar;
+  int              bands;
+  BablComponent  **component;
+  BablType       **type;
+  BablSampling   **sampling;
+  BablConversion  *to_conversions;
+  BablConversion  *from_conversions;
+} BablPixelFormat;
+
+typedef struct
+{
+  BablInstance           instance;
+  union Babl            *source;
+  union Babl            *destination;
+} BablFish;
+
+typedef union
+{
+  BablClassType   kind;
+  BablInstance    instance;
+  BablType        type;
+  BablSampling    sampling;
+  BablComponent   component;
+  BablModel       model;
+  BablPixelFormat pixel_format;
+  BablConversion  conversion;
+  BablFish        fish;
+} Babl;
+
+
+#define BABL_NAME(obj)          (((Babl*)(obj))->instance.name)
+#define BABL_INSTANCE_TYPE(obj) (((Babl*)(obj))->kind)
+
+#define BABL_IS_BABL(obj)\
+(NULL==(obj)?0:BABL_CLASS_TYPE_IS_VALID(BABL_INSTANCE_TYPE(obj)))
+
+#define BABL_IS_OF_KIND(obj,kind) \
+    (!BABL_IS_BABL(obj)?0:kind==BABL_INSTANCE_TYPE(obj)?1:0)
+
+#define BABL_IS_INSTANCE(obj)      BABL_IS_OF_KIND(obj,BABL_TYPE)
+#define BABL_IS_TYPE(obj)          BABL_IS_OF_KIND(obj,BABL_TYPE)
+#define BABL_IS_COMPONENT(obj)     BABL_IS_OF_KIND(obj,BABL_COMPONENT)
+#define BABL_IS_SAMPLING(obj)      BABL_IS_OF_KIND(obj,BABL_SAMPLING)
+#define BABL_IS_PIXEL_FORMAT(obj)  BABL_IS_OF_KIND(obj,BABL_PIXEL_FORMAT)
+
+typedef int  (*BablEachFunction) (Babl *entry,
+                                  void *data);
+
+const char  *babl_class_name     (BablClassType klass);
+
+#define BABL_DEFINE_CLASS(TypeName, type_name)                   \
+                                                                 \
+void       type_name##_init       (void);                        \
+void       type_name##_each       (BablEachFunction  each_fun,   \
+                                   void             *user_data); \
+void       type_name##_destroy    (void);                        \
+TypeName * type_name              (const char       *name);      \
+TypeName * type_name##_id         (int               id);        \
+TypeName * type_name##_new        (const char       *name,       \
+                                   ...);
+
+#endif
+
diff --git a/babl/babl-component.c b/babl/babl-component.c
new file mode 100644 (file)
index 0000000..ea1e361
--- /dev/null
@@ -0,0 +1,150 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl-internal.h"
+#include "babl-db.h"
+#include <string.h>
+
+#include <stdarg.h>
+
+
+static int 
+each_babl_component_destroy (Babl *babl,
+                             void *data)
+{
+  babl_free (babl->component.from);
+  babl_free (babl->component.to);
+  babl_free (babl->instance.name);
+  babl_free (babl);
+  return 0;  /* continue iterating */
+}
+
+static BablComponent *
+component_new (const char *name,
+               int         id,
+               int         luma,
+               int         chroma,
+               int         alpha)
+{
+  BablComponent *self;
+
+  self                = babl_calloc (sizeof (BablComponent), 1);
+  self->instance.type = BABL_COMPONENT;
+  self->instance.id   = id;
+  self->instance.name = babl_strdup (name);
+  self->luma       = luma;
+  self->chroma     = chroma;
+  self->alpha      = alpha;
+
+  return self;
+}
+
+BablComponent *
+babl_component_new (const char *name,
+                    ...)
+{
+  va_list varg;
+  BablComponent *self;
+  int            id         = 0;
+  int            luma    = 0;
+  int            chroma  = 0;
+  int            alpha   = 0;
+  const char    *arg=name;
+
+  va_start (varg, name);
+  
+  while (1)
+    {
+      arg = va_arg (varg, char *);
+      if (!arg)
+        break;
+      
+      if (BABL_IS_BABL (arg))
+        {
+          Babl *babl = (Babl*)arg;
+
+          switch (BABL_INSTANCE_TYPE (arg))
+            {
+              case BABL_TYPE:
+              case BABL_INSTANCE:
+              case BABL_COMPONENT:
+              case BABL_PIXEL_FORMAT:
+              case BABL_MODEL:
+              case BABL_SAMPLING:
+
+              case BABL_CONVERSION:
+              case BABL_CONVERSION_TYPE:
+              case BABL_CONVERSION_TYPE_PLANAR:
+              case BABL_CONVERSION_MODEL_PLANAR:
+              case BABL_CONVERSION_PIXEL_FORMAT:
+              case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
+              case BABL_FISH:
+                babl_log ("%s(): %s unexpected",
+                          __FUNCTION__, babl_class_name (babl->instance.type));
+                break;
+              case BABL_SKY: /* shut up compiler */
+                break;
+            }
+        }
+      /* if we didn't point to a babl, we assume arguments to be strings */
+      else if (!strcmp (arg, "id"))
+        {
+          id = va_arg (varg, int);
+        }
+      
+      else if (!strcmp (arg, "luma"))
+        {
+          luma = 1;
+        }
+      
+      else if (!strcmp (arg, "chroma"))
+        {
+          chroma = 1;
+        }
+
+
+      else if (!strcmp (arg, "alpha"))
+        {
+          alpha = 1;
+        }
+      
+      else
+        {
+          babl_log ("%s(): unhandled parameter '%s' for pixel_format '%s'",
+                    __FUNCTION__, arg, name);
+          exit (-1);
+        }
+    }
+    
+  va_end   (varg);
+
+  self = component_new (name, id, luma, chroma, alpha);
+
+  if ((BablComponent*) db_insert ((Babl*)self) == self)
+    {
+      return self;
+    }
+  else
+    {
+      each_babl_component_destroy ((Babl*)self, NULL);
+      return NULL;
+    }
+}
+
+BABL_CLASS_TEMPLATE(BablComponent, babl_component, "BablComponent")
diff --git a/babl/babl-component.h b/babl/babl-component.h
new file mode 100644 (file)
index 0000000..17a1ee0
--- /dev/null
@@ -0,0 +1,26 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_COMPONENT_H
+#define _BABL_COMPONENT_H
+
+#include "babl-classes.h"
+BABL_DEFINE_CLASS(BablComponent, babl_component)
+
+#endif
diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c
new file mode 100644 (file)
index 0000000..8cddb12
--- /dev/null
@@ -0,0 +1,243 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl-internal.h"
+#include "babl-db.h"
+#include "assert.h"
+#include <string.h>
+#include <stdarg.h>
+
+static int 
+each_babl_conversion_destroy (Babl *babl,
+                         void *data)
+{
+  babl_free (babl->instance.name);
+  babl_free (babl);
+  return 0;  /* continue iterating */
+}
+
+static BablConversion *
+conversion_new (const char                      *name,
+                int                              id,
+                Babl                            *source,
+                Babl                            *destination,
+                int                              time_cost,
+                int                              loss,
+                BablFuncLinear     linear,
+                BablFuncPlanar     planar,
+                BablFuncPlanarBit  planar_bit)
+{
+  BablConversion *self = NULL;
+
+  /* destination is of same type as source */ 
+  switch (BABL_INSTANCE_TYPE (source))
+    {
+      case BABL_TYPE:
+        if (linear)
+          {
+            self = babl_calloc (sizeof (BablConversionType), 1);
+            self->instance.type = BABL_CONVERSION_TYPE;
+            self->function.linear = linear;
+          }
+        else if (planar)
+          {
+            self = babl_calloc (sizeof (BablConversionTypePlanar), 1);
+            self->instance.type = BABL_CONVERSION_TYPE_PLANAR;
+            self->function.planar = planar;
+          }
+        else if (planar_bit)
+          {
+            babl_log ("%s(): planar_bit support not implemented yet",
+                      __FUNCTION__);
+          }
+        break;
+      case BABL_SAMPLING:
+        babl_log ("%s(): sampling conversions not implemented yet\n",
+                  __FUNCTION__);
+        break;
+      case BABL_COMPONENT:
+        babl_log ("%s(): component conversions do not make sense (except perhaps for gamma correction)\n",
+                  __FUNCTION__);
+        break;
+      case BABL_MODEL:
+        if (linear)
+          {
+            babl_log ("%s(): linear support for model conversion not supported",
+                      __FUNCTION__);
+          }
+        else if (planar)
+          {
+            self = babl_calloc (sizeof (BablConversionModelPlanar), 1);
+            self->instance.type = BABL_CONVERSION_MODEL_PLANAR;
+            self->function.planar = planar;
+          }
+        else if (planar_bit)
+          {
+            babl_log ("%s(): planar_bit support for model conversion not supported",
+                      __FUNCTION__);
+          }
+        break;
+
+      case BABL_PIXEL_FORMAT:
+        if (linear)
+          {
+            self = babl_calloc (sizeof (BablConversionPixelFormat), 1);
+            self->instance.type = BABL_CONVERSION_PIXEL_FORMAT;
+            self->function.linear = linear;
+          }
+        else if (planar)
+          {
+            self = babl_calloc (sizeof (BablConversionPixelFormatPlanar), 1);
+            self->instance.type = BABL_CONVERSION_PIXEL_FORMAT_PLANAR;
+            self->function.planar = planar;
+          }
+        else if (planar_bit)
+          {
+            babl_log ("%s(): planar_bit support for pixelformat conversion not supported",
+                      __FUNCTION__);
+          }
+        break;
+      default:
+        break;
+    }
+  if (!self)
+    {
+      babl_log ("%s(name='%s', ...): creation failed", __FUNCTION__, name);
+      return NULL;
+    }
+
+  self->instance.id   = id;
+  self->instance.name = babl_strdup (name);
+  self->source        = (union Babl*)source;
+  self->destination   = (union Babl*)destination;
+  self->time_cost     = time_cost;
+  self->loss          = loss;
+
+  assert (BABL_IS_BABL (self->source));
+  assert (BABL_IS_BABL (self->destination));
+
+  babl_add_ptr_to_list ((void ***)&(source->type.from), self);
+  babl_add_ptr_to_list ((void ***)&(destination->type.to), self);
+  
+  return (BablConversion*)self;
+}
+
+BablConversion *
+babl_conversion_new (const char *name,
+                     ...)
+{
+  va_list            varg;
+  BablConversion    *self;
+
+  int                id          = 0;
+  Babl              *source      = NULL;
+  Babl              *destination = NULL;
+  int                time_cost   = 0;
+  int                loss        = 0;
+  BablFuncLinear     linear      = NULL;
+  BablFuncPlanar     planar      = NULL;
+  BablFuncPlanarBit  planar_bit  = NULL;
+
+  int                got_func    = 0;
+  const char        *arg         = name;
+
+  va_start (varg, name);
+  
+  while (1)
+    {
+      arg = va_arg (varg, char *);
+      if (!arg)
+        break;
+     
+      else if (!strcmp (arg, "id"))
+        {
+          id = va_arg (varg, int);
+        }
+      
+      else if (!strcmp (arg, "linear"))
+        {
+          if (got_func++)
+            {
+              babl_log ("%s(): already got a conversion func, registration of multiple might be possible later\n",
+              __FUNCTION__); 
+            }
+          linear = va_arg (varg, BablFuncLinear);
+        }
+
+      else if (!strcmp (arg, "planar"))
+        {
+          if (got_func++)
+            {
+              babl_log ("%s(): already got a conversion func, registration of multiple might be possible later\n",
+              __FUNCTION__); 
+            }
+          planar = va_arg (varg, BablFuncPlanar);
+        }
+
+      else if (!strcmp (arg, "planar-bit"))
+        {
+          if (got_func++)
+            {
+              babl_log ("%s(): already got a conversion func, registration of multiple might be possible later\n",
+              __FUNCTION__); 
+            }
+          planar_bit = va_arg (varg, BablFuncPlanarBit);
+        }
+
+      else if (!strcmp (arg, "time-cost"))
+        {
+          time_cost = va_arg (varg, int);
+        }
+      else if (!strcmp (arg, "loss"))
+        {
+          loss = va_arg (varg, int);
+        }
+      else if (!strcmp (arg, "source"))
+        {
+          source = va_arg (varg, Babl*);
+        }
+      else if (!strcmp (arg, "destination"))
+        {
+          destination = va_arg (varg, Babl*);
+        }
+      else
+        {
+          babl_log ("%s(): unhandled parameter '%s' for pixel_format '%s'",
+                    __FUNCTION__, arg, name);
+          exit (-1);
+        }
+    }
+    
+  va_end   (varg);
+
+  self = conversion_new (name, id,
+                         source, destination, time_cost, loss, linear, planar, planar_bit);
+
+  if ((BablConversion*) db_insert ( (Babl*)self) == self)
+    {
+      return self;
+    }
+  else
+    {
+      each_babl_conversion_destroy ( (Babl*)self, NULL);
+      return NULL;
+    }
+}
+
+BABL_CLASS_TEMPLATE(BablConversion, babl_conversion, "BablConversion")
diff --git a/babl/babl-conversion.h b/babl/babl-conversion.h
new file mode 100644 (file)
index 0000000..064e593
--- /dev/null
@@ -0,0 +1,26 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef BABL_CONVERSION_H
+#define BABL_CONVERSION_H
+
+#include "babl-classes.h"
+BABL_DEFINE_CLASS(BablConversion, babl_conversion)
+
+#endif
diff --git a/babl/babl-db.h b/babl/babl-db.h
new file mode 100644 (file)
index 0000000..7b4b7e5
--- /dev/null
@@ -0,0 +1,196 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifndef _DB_H
+#define _DB_H
+
+#ifndef _BABL_INTERNAL_H
+#error  babl-internal.h must be included before babl-db.h, babl-db.h is strictly internal to babl core classes.
+#endif
+
+#include "babl-classes.h"
+
+#include <string.h>
+
+#define DB_DEF             static inline
+#define DB_INITIAL_SIZE    0
+#define DB_INCREMENT_SIZE  16
+
+
+/* file scope variables, for this .c file's database */
+static int    db_size     = 0;
+static int    db_entries  = 0;
+static Babl **db;
+
+DB_DEF void   db_init    (void);
+DB_DEF void   db_destroy (void);
+DB_DEF void   db_each    (BablEachFunction  each_fun,
+                          void             *user_data);
+DB_DEF Babl * db_insert  (Babl  *entry);
+DB_DEF Babl * db_exist   (int    id,
+                          const char *name);
+
+DB_DEF Babl * db_find    (const char *name)
+{
+  Babl *ret = db_exist (0, name);
+
+  if (!ret)
+    {
+      const char *sample_type = "unknwon";
+
+      if (db[0])
+        sample_type = babl_class_name (db[0]->instance.type);
+      babl_log ("%s(\"%s\"): failed (query performed on a %s database)",
+       __FUNCTION__, name, sample_type);
+    }
+  return ret;
+}
+
+
+DB_DEF void
+db_init(void)
+{
+  if (0==db_size)
+    {
+      db_size = DB_INITIAL_SIZE;
+      db = babl_malloc (db_size * sizeof (BablInstance*));
+      memset (db, 0, db_size * sizeof (BablInstance*));
+    }
+}
+
+
+DB_DEF void
+db_destroy (void)
+{
+  babl_free (db);
+  db_size    = 0;
+  db_entries = 0;
+  db         = NULL;
+}
+
+
+DB_DEF Babl *
+db_insert (Babl *babl)
+{
+  Babl *collision;
+
+  if (!babl)
+    {
+      babl_log ("%s(babl=%p)", __FUNCTION__, babl);
+      return NULL;
+    }
+
+  collision = db_exist (babl->instance.id, babl->instance.name);
+
+  if (collision)
+    {
+      if (collision->instance.id == babl->instance.id)
+        babl_log ("%s: conflicting id: existing(%i:'%s') - new(%i:'%s')",
+                __FUNCTION__, collision->instance.id, collision->instance.name,
+                babl->instance.id, babl->instance.name);
+      else if (!strcmp (collision->instance.name, babl->instance.name))
+        babl_log ("%s: conflicting name: existing(%i:'%s') - new(%i:'%s')",
+                __FUNCTION__, collision->instance.id, collision->instance.name,
+                babl->instance.id, babl->instance.name);
+      return collision;
+    }
+
+  if (db_entries + 1 > db_size)     /* must reallocate storage */
+    {
+      Babl **new_db;
+
+      new_db = babl_realloc (db, (db_size + DB_INCREMENT_SIZE) * sizeof (BablInstance*));
+      if (!new_db)
+        {
+          babl_log ("db_insert: unable to reallocate memory, element (%i:'%s') not inserted", babl->instance.id, babl->instance.name);
+          return NULL;
+        }
+      db = new_db;
+
+      /* null out the currently unused portions of memory */
+      memset (db + db_size, 0, DB_INCREMENT_SIZE * sizeof (Babl*));
+      db_size += DB_INCREMENT_SIZE;
+    }
+  db[db_entries++]=babl;
+  return babl;
+}
+
+
+DB_DEF void
+db_each (BablEachFunction  each_fun,
+         void      *user_data)
+{
+  int i;
+
+  for (i=0; i< db_entries; i++)
+    {
+      if (db[i])
+        {
+          if (each_fun ((Babl*) db[i], user_data))
+            break;
+        }
+    }
+}
+
+typedef struct DbExistData
+{
+  unsigned int  type;
+  int           id;
+  const char   *name;
+  Babl         *ret;
+} DbExistData;
+
+DB_DEF int 
+db_each_exist (Babl *babl,
+               void *void_data)
+{
+  DbExistData *data = void_data;
+
+  if (data->id &&
+      data->id == babl->instance.id)
+    {
+      data->ret = babl;
+      return 1;
+    }
+  if (data->name &&
+      !strcmp (babl->instance.name, data->name))
+    {
+      data->ret = babl;
+      return 1;
+    }
+  return 0;  /* continue iterating */
+}
+
+DB_DEF Babl * 
+db_exist (int         id,
+          const char *name)
+{
+  DbExistData data;
+
+  data.id = id;
+  data.name = name;
+  data.ret = NULL;
+
+  db_each (db_each_exist, &data);
+
+  return data.ret;
+}
+
+#endif
diff --git a/babl/babl-fish.c b/babl/babl-fish.c
new file mode 100644 (file)
index 0000000..c6fca4f
--- /dev/null
@@ -0,0 +1,122 @@
+/* babl - dynamically extendable universal pixel fish library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl-internal.h"
+#include "babl-db.h"
+#include "assert.h"
+#include <string.h>
+#include <stdarg.h>
+
+static int 
+each_babl_fish_destroy (Babl *babl,
+                        void *data)
+{
+  babl_free (babl->instance.name);
+  babl_free (babl);
+  return 0;  /* continue iterating */
+}
+
+static BablFish *
+fish_new (const char              *name,
+                int                id,
+                Babl              *source,
+                Babl              *destination)
+{
+  BablFish *self = NULL;
+
+  self = babl_calloc (sizeof (BablFish), 1);
+  self->instance.type = BABL_FISH;
+
+  self->instance.id   = id;
+  self->instance.name = babl_strdup (name);
+  self->source        = (union Babl*)source;
+  self->destination   = (union Babl*)destination;
+
+  assert (BABL_IS_BABL (self->source));
+  assert (BABL_IS_BABL (self->destination));
+
+/*  Might make sense to allow a precalculated shortcut to
+ *  participate in later checks for optimal conversions
+  
+    babl_add_ptr_to_list ((void ***)&(source->type.from), self);
+    babl_add_ptr_to_list ((void ***)&(destination->type.to), self);
+  */
+  
+  return (BablFish*)self;
+}
+
+BablFish *
+babl_fish_new (const char *name,
+                     ...)
+{
+  va_list            varg;
+  BablFish    *self;
+
+  int                id          = 0;
+  Babl              *source      = NULL;
+  Babl              *destination = NULL;
+
+  const char        *arg         = name;
+
+  va_start (varg, name);
+  
+  while (1)
+    {
+      arg = va_arg (varg, char *);
+      if (!arg)
+        break;
+     
+      else if (!strcmp (arg, "id"))
+        {
+          id = va_arg (varg, int);
+        }
+
+      else if (!strcmp (arg, "source"))
+        {
+          source = va_arg (varg, Babl*);
+        }
+      else if (!strcmp (arg, "destination"))
+        {
+          destination = va_arg (varg, Babl*);
+        }
+      else
+        {
+          babl_log ("%s(): unhandled parameter '%s' for pixel_format '%s'",
+                    __FUNCTION__, arg, name);
+          exit (-1);
+        }
+    }
+    
+  va_end   (varg);
+
+  self = fish_new (name, id,
+                         source, destination);
+
+  if ((BablFish*) db_insert ( (Babl*)self) == self)
+    {
+      return self;
+    }
+  else
+    {
+      each_babl_fish_destroy ( (Babl*)self, NULL);
+      return NULL;
+    }
+}
+
+BABL_CLASS_TEMPLATE(BablFish, babl_fish, "BablFish")
diff --git a/babl/babl-fish.h b/babl/babl-fish.h
new file mode 100644 (file)
index 0000000..d3b0fe1
--- /dev/null
@@ -0,0 +1,26 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef BABL_FISH_H
+#define BABL_FISH_H
+
+#include "babl-classes.h"
+BABL_DEFINE_CLASS(BablFish, babl_fish)
+
+#endif
diff --git a/babl/babl-format.c b/babl/babl-format.c
new file mode 100644 (file)
index 0000000..3f9c254
--- /dev/null
@@ -0,0 +1,199 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <string.h>
+#include <stdarg.h>
+
+#include "babl-internal.h"
+#include "babl-sampling.h"
+#include "babl-type.h"
+#include "babl-component.h"
+#include "babl-db.h"
+
+#define BABL_MAX_BANDS 32
+
+static int 
+each_babl_pixel_format_destroy (Babl *babl,
+                                void *data)
+{
+  babl_free (babl->pixel_format.from);
+  babl_free (babl->pixel_format.to);
+  babl_free (babl->pixel_format.component);
+  babl_free (babl->pixel_format.type);
+  babl_free (babl->pixel_format.sampling);
+  babl_free (babl->instance.name);
+  babl_free (babl);
+
+  return 0;  /* continue iterating */
+}
+
+static BablPixelFormat *
+pixel_format_new (const char     *name,
+                  int             id,
+                  int             planar,
+                  int             bands,
+                  BablComponent **band_component,
+                  BablSampling  **band_sampling,
+                  BablType      **band_type)
+{
+  BablPixelFormat *self;
+  int              band;
+
+  self                     = babl_calloc (sizeof (BablPixelFormat), 1);
+
+  self->instance.type = BABL_PIXEL_FORMAT;
+  self->instance.id   = id;
+  self->instance.name = babl_strdup (name);
+
+  self->bands         = bands;
+  self->planar        = planar;
+
+  self->component     = babl_malloc (sizeof (BablComponent*) * (bands+1));
+  self->type          = babl_malloc (sizeof (BablType*)      * (bands+1));
+  self->sampling      = babl_malloc (sizeof (BablSampling*)  * (bands+1));
+
+  for (band=0; band < bands; band++)
+    {
+      self->component[band] = band_component[band];
+      self->type[band] = band_type[band];
+      self->sampling[band] = band_sampling[band];
+    }
+  self->component[band] = NULL;
+  self->type[band]      = NULL;
+  self->sampling[band]  = NULL;
+
+  return self;
+}
+
+BablPixelFormat *
+babl_pixel_format_new (const char *name,
+                       ...)
+{
+  va_list varg;
+  BablPixelFormat *self;
+  int              id     = 0;
+  int              planar = 0;
+  int              bands  = 0;
+  BablComponent   *band_component [BABL_MAX_BANDS];
+  BablSampling    *band_sampling  [BABL_MAX_BANDS];
+  BablType        *band_type      [BABL_MAX_BANDS];
+
+  BablSampling    *current_sampling = babl_sampling (1,1);
+  BablType        *current_type     = babl_type_id (BABL_U8);
+  const char      *arg=name;
+
+  va_start (varg, name);
+
+  
+  while (1)
+    {
+      arg = va_arg (varg, char *);
+      if (!arg)
+        break;
+
+
+      if (BABL_IS_BABL (arg))
+        {
+          Babl *babl = (Babl*)arg;
+
+          switch (BABL_INSTANCE_TYPE (arg))
+            {
+              case BABL_TYPE:
+                current_type = (BablType*) babl;
+                break;
+              case BABL_COMPONENT:
+                band_component [bands] = (BablComponent*) babl;
+                band_type      [bands] = current_type;
+                band_sampling  [bands] = current_sampling;
+                bands++;
+
+                if (bands>=BABL_MAX_BANDS)
+                  {
+                    babl_log ("maximum number of bands (%i) exceeded for %s",
+                              BABL_MAX_BANDS, name);
+                  }
+                break;
+              case BABL_SAMPLING:
+                  current_sampling = (BablSampling*)arg;
+                  break;
+              case BABL_INSTANCE:
+              case BABL_MODEL:
+                babl_log ("%s(): %s not handled in pixel format yet",
+                          __FUNCTION__, babl_class_name (babl->instance.type));
+                  break;
+              case BABL_PIXEL_FORMAT:
+
+              case BABL_CONVERSION:
+              case BABL_CONVERSION_TYPE:
+              case BABL_CONVERSION_TYPE_PLANAR:
+              case BABL_CONVERSION_MODEL_PLANAR:
+              case BABL_CONVERSION_PIXEL_FORMAT:
+              case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
+              case BABL_FISH:
+                babl_log ("%s(): %s unexpected",
+                          __FUNCTION__, babl_class_name (babl->instance.type));
+                break;
+              case BABL_SKY: /* shut up compiler */
+                break;
+            }
+        }
+      /* if we didn't point to a babl, we assume arguments to be strings */
+      else if (!strcmp (arg, "id"))
+        {
+          id = va_arg (varg, int);
+        }
+      
+      else if (!strcmp (arg, "packed"))
+        {
+          planar = 0;
+        }
+      
+      else if (!strcmp (arg, "planar"))
+        {
+          planar = 1;
+        }
+      
+      else
+        {
+          babl_log ("%s: unhandled parameter '%s' for pixel_format '%s'",
+                    __FUNCTION__, arg, name);
+          exit (-1);
+        }
+    }
+    
+  va_end   (varg);
+
+
+  self =pixel_format_new (name, id,
+                          planar,
+                          bands, band_component, band_sampling, band_type);
+
+  
+  if ((BablPixelFormat*) db_insert ((Babl*)self) == self)
+    {
+      return self;
+    }
+  else
+    {
+      each_babl_pixel_format_destroy ((Babl*)self, NULL);
+      return NULL;
+    }
+}
+
+BABL_CLASS_TEMPLATE (BablPixelFormat, babl_pixel_format, "BablPixelFormat")
diff --git a/babl/babl-format.h b/babl/babl-format.h
new file mode 100644 (file)
index 0000000..a9d7977
--- /dev/null
@@ -0,0 +1,26 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_PIXEL_FORMAT_H
+#define _BABL_PIXEL_FORMAT_H
+
+#include "babl-classes.h"
+BABL_DEFINE_CLASS(BablPixelFormat, babl_pixel_format)
+
+#endif
diff --git a/babl/babl-ids.h b/babl/babl-ids.h
new file mode 100644 (file)
index 0000000..6202121
--- /dev/null
@@ -0,0 +1,96 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_IDS_H
+#define _BABL_IDS_H
+
+enum {
+  BABL_UNDEFINED = 0,
+  BABL_TYPE_BASE = 100,
+  BABL_U8,
+  BABL_U16,
+  BABL_FLOAT,
+  BABL_DOUBLE,
+  BABL_HALF_FLOAT,
+
+  BABL_COMPONENT_BASE = 1000,
+  BABL_RED,
+  BABL_GREEN,
+  BABL_BLUE,
+  BABL_ALPHA,
+  BABL_LUMINANCE,
+  BABL_RED_MUL_ALPHA,
+  BABL_GREEN_MUL_ALPHA,
+  BABL_BLUE_MUL_ALPHA,
+  BABL_RED_GAMMA_2_2,
+  BABL_GREEN_GAMMA_2_2,
+  BABL_BLUE_GAMMA_2_2,
+  BABL_CYAN,
+  BABL_MAGENTA,
+  BABL_YELLOW,
+  BABL_KEY,
+  BABL_CB,
+  BABL_CR,
+  BABL_LAB_L,
+  BABL_LAB_A,
+  BABL_LAB_B,
+  BABL_X,
+  BABL_Y,
+  BABL_Z,
+  BABL_Z_BUFFER,
+  BABL_PADDING,
+
+  BABL_MODEL_BASE = 10000,
+  BABL_RGB,
+  BABL_RGBA,
+  BABL_RGBA_PREMULTIPLIED,
+  BABL_RGB_GAMMA_2_2,
+  BABL_RGBA_GAMMA_2_2,
+  BABL_CMY,
+  BABL_CMYK,
+  BABL_CMYKA,
+  BABL_YCBCR,
+  BABL_GRAYSCALE,
+  BABL_GRAYSCALE_ALPHA,
+
+  BABL_PIXEL_FORMAT_BASE = 100000,
+  BABL_SRGB,
+  BABL_SRGBA,
+  BABL_RGB_FLOAT,
+  BABL_RGBA_FLOAT,
+  BABL_CMYK_FLOAT,
+  BABL_CMYKA_FLOAT,
+  BABL_YUV420,
+#if 0
+  BABL_RGB_U8,
+  BABL_RGBA_U8,
+  BABL_RGBA_U16,
+  BABL_RGBA_FLOAT,
+  BABL_YUV411,
+  BABL_YUV422,
+#endif
+
+  BABL_PIXEL_USER_BASE,
+};
+
+
+#endif
+
+
+
diff --git a/babl/babl-internal.c b/babl/babl-internal.c
new file mode 100644 (file)
index 0000000..6303c9f
--- /dev/null
@@ -0,0 +1,47 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl-classes.h"
+
+static const char *class_names[] =
+  {
+    "BablInstance",
+    "BablType",
+    "BablSampling",
+    "BablComponent",
+    "BablModel",
+    "BablPixelFormat",
+    "BablConversion",
+    "BablConversionType",
+    "BablConversionTypePlanar",
+    "BablConversionModelPlanar",
+    "BablConversionPixelFormatPlanar",
+    "BablConversionPixelFormatPlanar",
+    "BablFish",
+    "BablCeiling"
+  };
+
+const char *
+babl_class_name (BablClassType klass)
+{
+  return class_names[klass-BABL_INSTANCE];
+}
+
+int babl_hmpf_on_name_lookups = 1;
+
diff --git a/babl/babl-internal.h b/babl/babl-internal.h
new file mode 100644 (file)
index 0000000..fffa022
--- /dev/null
@@ -0,0 +1,90 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_INTERNAL_H
+#define _BABL_INTERNAL_H
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "babl-ids.h"
+#include "babl-util.h"
+#include "babl-memory.h"
+#include "babl-classes.h"
+
+#define babl_log(fmt, args...) do {      \
+  fprintf (stdout, "babl: ");            \
+  fprintf (stdout, fmt, args);           \
+  fprintf (stdout, "\n");                \
+} while (0)
+
+
+extern int babl_hmpf_on_name_lookups;
+
+#define BABL_DEFINE_EACH(type_name)                           \
+void                                                          \
+type_name##_each (BablEachFunction  each_fun,                 \
+                     void          *user_data)                \
+{                                                             \
+  db_each (each_fun, user_data);                              \
+}                                                             \
+
+#define BABL_DEFINE_LOOKUP_BY_ID(TypeName, type_name)         \
+TypeName *                                                    \
+type_name##_id (int id)                                       \
+{                                                             \
+  return (TypeName*) db_exist (id, NULL);                     \
+}
+
+#define BABL_DEFINE_LOOKUP_BY_NAME(TypeName, type_name)       \
+TypeName *                                                    \
+type_name (const char *name)                                  \
+{                                                             \
+  if (babl_hmpf_on_name_lookups)                              \
+    {                                                         \
+      babl_log ("%s(\"%s\"): hmpf!", __FUNCTION__, name);     \
+    }                                                         \
+  return (TypeName*) db_exist (0, name);                      \
+}
+
+#define BABL_DEFINE_INIT(type_name)                           \
+void                                                          \
+type_name##_init (void)                                       \
+{                                                             \
+  db_init ();                                                 \
+}
+
+#define BABL_DEFINE_DESTROY(type_name)                        \
+void                                                          \
+type_name##_destroy (void)                                    \
+{                                                             \
+  db_each (each_##type_name##_destroy, NULL);                 \
+  db_destroy ();                                              \
+}
+
+#define BABL_CLASS_TEMPLATE(TypeName, type_name, type_string) \
+BABL_DEFINE_INIT           (type_name)                        \
+BABL_DEFINE_DESTROY        (type_name)                        \
+BABL_DEFINE_LOOKUP_BY_NAME (TypeName, type_name)              \
+BABL_DEFINE_EACH           (type_name)                        \
+BABL_DEFINE_LOOKUP_BY_ID   (TypeName, type_name)               
+
+
+#endif
diff --git a/babl/babl-introspect.c b/babl/babl-introspect.c
new file mode 100644 (file)
index 0000000..ca29cd9
--- /dev/null
@@ -0,0 +1,188 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl.h"
+#include "babl-internal.h"    /* for babl_log */
+
+static void sampling_introspect     (Babl *babl);
+static void model_introspect        (Babl *babl);
+static void type_introspect         (Babl *babl);
+static void pixel_format_introspect (Babl *babl);
+static int  each_introspect         (Babl *babl,
+                                     void *user_data);
+
+void
+babl_introspect (void)
+{
+  babl_log ("Introspection report%s","");  
+  babl_log ("====================================================%s" ,"");  
+
+  babl_log ("%s","");
+  babl_log ("Data Types:%s", "");
+  babl_type_each         (each_introspect, NULL);
+  babl_log ("%s","");
+  babl_log ("Sampling (chroma subsampling) factors:%s", "");
+  babl_sampling_each     (each_introspect, NULL);
+  babl_log ("%s","");
+  babl_log ("Components:%s", "");
+  babl_component_each    (each_introspect, NULL);
+  babl_log ("%s","");
+  babl_log ("Models (of components):%s", "");
+  babl_model_each        (each_introspect, NULL);
+  babl_log ("%s","");
+  babl_log ("Pixel formats:%s", "");
+  babl_pixel_format_each (each_introspect, NULL);
+  babl_log ("%s","");
+  babl_log ("conversions:%s", "");
+  babl_conversion_each   (each_introspect, NULL);
+  babl_log ("%s","");
+  babl_log ("fishes:%s", "");
+  babl_fish_each         (each_introspect, NULL);
+
+  babl_log ("%s", "");
+}
+
+static int list_length (void **list)
+{
+  void **ptr;
+  int    len=0;
+  
+  ptr = list;
+  while (NULL!=*ptr)
+    {
+      ptr++;
+      len++;
+    }
+  return len;
+}
+
+
+static void
+item_conversions_introspect (Babl *babl)
+{
+  void **ptr;
+
+  if (babl->type.from)
+    babl_log ("\t\tconversions from %s: %i",
+       babl->instance.name, list_length ((void **)(babl->type.from)));
+
+  ptr = (void **)babl->type.from;
+
+  while (ptr && NULL!=*ptr)
+    {
+      babl_log ("\t\t\t'%s'", ((Babl *)(*ptr))->instance.name);
+      ptr++;
+    }
+  
+  if (babl->type.to)
+    babl_log ("\t\tconversions to %s: %i",
+       babl->instance.name, list_length ((void **)(babl->type.to)));
+
+
+  ptr = (void **)babl->type.to;
+
+  while (ptr && NULL!=*ptr)
+    {
+      babl_log ("\t\t\t'%s'", ((Babl *)(*ptr))->instance.name);
+      ptr++;
+    }
+}
+
+static void
+model_introspect (Babl *babl)
+{
+  int i;
+  babl_log ("\t\tcomponents=%i", babl->model.components);
+
+  for (i=0; i< babl->model.components; i++)
+    {
+      babl_log ("\t\tindex[%i] = '%s'",
+                i, BABL_NAME (babl->model.component[i]));
+    }
+}
+
+static void
+type_introspect (Babl *babl)
+{
+  babl_log ("\t\tbits=%i", babl->type.bits);
+}
+
+
+static void
+sampling_introspect (Babl *babl)
+{
+  babl_log ("\t\thorizontal = %i",
+            babl->sampling.horizontal);
+  babl_log ("\t\tvertical   = %i",
+            babl->sampling.vertical);
+}
+
+
+static void
+pixel_format_introspect (Babl *babl)
+{
+  int i;
+  babl_log ("\t\tplanar=%i", babl->pixel_format.planar);
+  babl_log ("\t\tbands=%i",  babl->pixel_format.bands);
+
+  for (i=0; i< babl->pixel_format.bands; i++)
+    {
+      babl_log ("\t\tband[%i] type='%s' component='%s'",
+                i, BABL_NAME (babl->pixel_format.type[i]),
+                   BABL_NAME (babl->pixel_format.component[i]));
+    }
+}
+
+static int
+each_introspect (Babl *babl,
+                 void *user_data)
+{
+  babl_log ("\t'%s'\t%i\t%s",
+   babl->instance.name,
+   babl->instance.id,
+   babl_class_name (babl->instance.type));
+  switch (babl->instance.type)
+    {
+      case BABL_TYPE:
+        type_introspect (babl);
+        item_conversions_introspect (babl);
+        break;
+      case BABL_COMPONENT:
+        item_conversions_introspect (babl);
+        break;
+      case BABL_MODEL:
+        model_introspect (babl);
+        item_conversions_introspect (babl);
+        break;
+      case BABL_PIXEL_FORMAT:
+        pixel_format_introspect (babl);
+        item_conversions_introspect (babl);
+        break;
+      case BABL_SAMPLING:
+        sampling_introspect (babl);
+        item_conversions_introspect (babl);
+        break;
+      case BABL_FISH:
+        babl_log ("\t\tneed more data here%s", "");
+        break;
+      default:
+        break;
+    }
+  return 0;
+}
diff --git a/babl/babl-introspect.h b/babl/babl-introspect.h
new file mode 100644 (file)
index 0000000..5dc0e43
--- /dev/null
@@ -0,0 +1,26 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_INTROSPECT_H
+#define _BABL_INTROSPECT_H
+
+void
+babl_introspect (void);
+
+#endif
diff --git a/babl/babl-memory.c b/babl/babl-memory.c
new file mode 100644 (file)
index 0000000..e7eb140
--- /dev/null
@@ -0,0 +1,116 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "babl-internal.h"
+
+static int mallocs=0;
+static int frees=0;
+static int strdups=0;
+static int reallocs=0;
+static int callocs=0;
+
+static const char *
+mem_stats (void)
+{
+  static char buf[128];
+  sprintf (buf, "mallocs:%i callocs:%i strdups:%i allocs:%i frees:%i reallocs:%i\t|",
+    mallocs, callocs, strdups, mallocs+callocs+strdups, frees, reallocs);
+  return buf;
+}
+
+void *
+babl_malloc (size_t size)
+{
+  void *ret;
+  ret = malloc (size);
+  if (!ret)
+    babl_log ("%s(%i): failed", __FUNCTION__, size);
+  mallocs++;
+  return ret;
+}
+
+char *
+babl_strdup (const char *s)
+{
+  char *ret;
+  ret = strdup (s);
+  if (!ret)
+    babl_log ("%s(%s): failed", __FUNCTION__, s);
+  strdups++;
+  return ret;
+}
+
+void
+babl_free (void *ptr)
+{
+  if (!ptr)
+    return;
+  free (ptr);
+  frees++;
+}
+
+void *
+babl_realloc (void   *ptr,
+              size_t  size)
+{
+  void *ret;
+  ret = realloc (ptr, size);
+
+  if (!ret)
+    babl_log ("%s(%p, %i): failed", __FUNCTION__, ptr, size);
+  
+  reallocs++;
+
+  if (!ptr)     /* to make the statistics work out */
+    mallocs++;
+
+  return ret;
+}
+
+void *
+babl_calloc (size_t nmemb,
+             size_t size)
+{
+  void *ret = calloc (nmemb, size);
+
+  if (!ret)
+    babl_log ("%s(%i, %i): failed", __FUNCTION__, nmemb, size);
+
+  callocs++;
+  return ret;
+}
+
+void
+babl_memory_sanity (void)
+{
+  if (frees != mallocs + strdups + callocs)
+    {
+      fprintf (stderr,
+"babl_memory usage does not add up!!!!!!!!\n"
+"%s\n"
+"balance: %i-%i=%i\n",
+  mem_stats(), (strdups+mallocs+callocs),frees, (strdups+mallocs+callocs)-frees);
+    }
+}
diff --git a/babl/babl-memory.h b/babl/babl-memory.h
new file mode 100644 (file)
index 0000000..5b8c0e4
--- /dev/null
@@ -0,0 +1,34 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_MEMORY_H
+#define _BABL_MEMORY_H
+
+void * babl_malloc          (size_t        size);
+void   babl_free            (void         *ptr);
+
+void * babl_realloc         (void         *ptr,
+                             size_t        size);
+
+void * babl_calloc          (size_t        nmemb,
+                             size_t        size);
+char * babl_strdup          (const char   *s);
+void   babl_memory_sanity   (void);
+
+#endif
diff --git a/babl/babl-model.c b/babl/babl-model.c
new file mode 100644 (file)
index 0000000..c0acc39
--- /dev/null
@@ -0,0 +1,158 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl-internal.h"
+#include <string.h>
+#include <stdarg.h>
+#include "babl-db.h"
+
+
+static int 
+each_babl_model_destroy (Babl *babl,
+                         void         *data)
+{
+  babl_free (babl->model.from);
+  babl_free (babl->model.to);
+  babl_free (babl->model.component);
+  babl_free (babl->instance.name);
+  babl_free (babl);
+  return 0;  /* continue iterating */
+}
+
+
+#define BABL_MAX_COMPONENTS 32
+
+static BablModel *
+model_new (const char     *name,
+           int             id,
+           int             components,
+           BablComponent **component)
+{
+  BablModel *self;
+  int        i; 
+
+  self                     = babl_calloc (sizeof (BablModel), 1);
+
+  self->instance.type = BABL_MODEL;
+  self->instance.id   = id;
+  self->instance.name = babl_strdup (name);
+
+  self->components    = components;
+
+  self->component     = babl_malloc (sizeof (BablComponent*) * (components+1));
+
+  for (i=0; i < components; i++)
+    {
+      self->component[i] = component[i];
+    }
+  self->component[i] = NULL;
+
+  return self;
+}
+
+BablModel *
+babl_model_new (const char *name,
+                       ...)
+{
+  va_list varg;
+  BablModel *self;
+  int              id     = 0;
+  int              components  = 0;
+  BablComponent   *band_component [BABL_MAX_COMPONENTS];
+  const char      *arg=name;
+
+  va_start (varg, name);
+
+  
+  while (1)
+    {
+      arg = va_arg (varg, char *);
+      if (!arg)
+        break;
+
+
+      if (BABL_IS_BABL (arg))
+        {
+          Babl *babl = (Babl*)arg;
+
+          switch (BABL_INSTANCE_TYPE (arg))
+            {
+              case BABL_COMPONENT:
+                band_component [components] = (BablComponent*) babl;
+                components++;
+
+                if (components>=BABL_MAX_COMPONENTS)
+                  {
+                    babl_log ("%s(): maximum number of components (%i) exceeded for %s",
+                     __FUNCTION__, BABL_MAX_COMPONENTS, name);
+                  }
+                break;
+              case BABL_MODEL:
+                  babl_log ("%s(): submodels not handled yet", __FUNCTION__);
+                  break;
+              case BABL_TYPE:
+              case BABL_SAMPLING:
+              case BABL_INSTANCE:
+              case BABL_PIXEL_FORMAT:
+
+
+              case BABL_CONVERSION:
+              case BABL_CONVERSION_TYPE:
+              case BABL_CONVERSION_TYPE_PLANAR:
+              case BABL_CONVERSION_MODEL_PLANAR:
+              case BABL_CONVERSION_PIXEL_FORMAT:
+              case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
+              case BABL_FISH:
+                babl_log ("%s(): %s unexpected",
+                          __FUNCTION__, babl_class_name (babl->instance.type));
+                break;
+              case BABL_SKY: /* shut up compiler */
+                break;
+            }
+        }
+      /* if we didn't point to a babl, we assume arguments to be strings */
+      else if (!strcmp (arg, "id"))
+        {
+          id = va_arg (varg, int);
+        }
+      
+      else
+        {
+          babl_log ("%s: unhandled parameter '%s' for babl_model '%s'",
+                    __FUNCTION__, arg, name);
+          exit (-1);
+        }
+    }
+    
+  va_end   (varg);
+
+  self = model_new (name, id, components, band_component);
+  
+  if ((BablModel*) db_insert ((Babl*)self) == self)
+    {
+      return self;
+    }
+  else
+    {
+      each_babl_model_destroy ((Babl*)self, NULL);
+      return NULL;
+    }
+}
+
+BABL_CLASS_TEMPLATE (BablModel, babl_model, "BablModel")
diff --git a/babl/babl-model.h b/babl/babl-model.h
new file mode 100644 (file)
index 0000000..31121ea
--- /dev/null
@@ -0,0 +1,26 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_pixel_format_H
+#define _BABL_pixel_format_H
+
+#include "babl-classes.h"
+BABL_DEFINE_CLASS(BablModel, babl_model)
+
+#endif
diff --git a/babl/babl-pixel-format.c b/babl/babl-pixel-format.c
new file mode 100644 (file)
index 0000000..3f9c254
--- /dev/null
@@ -0,0 +1,199 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <string.h>
+#include <stdarg.h>
+
+#include "babl-internal.h"
+#include "babl-sampling.h"
+#include "babl-type.h"
+#include "babl-component.h"
+#include "babl-db.h"
+
+#define BABL_MAX_BANDS 32
+
+static int 
+each_babl_pixel_format_destroy (Babl *babl,
+                                void *data)
+{
+  babl_free (babl->pixel_format.from);
+  babl_free (babl->pixel_format.to);
+  babl_free (babl->pixel_format.component);
+  babl_free (babl->pixel_format.type);
+  babl_free (babl->pixel_format.sampling);
+  babl_free (babl->instance.name);
+  babl_free (babl);
+
+  return 0;  /* continue iterating */
+}
+
+static BablPixelFormat *
+pixel_format_new (const char     *name,
+                  int             id,
+                  int             planar,
+                  int             bands,
+                  BablComponent **band_component,
+                  BablSampling  **band_sampling,
+                  BablType      **band_type)
+{
+  BablPixelFormat *self;
+  int              band;
+
+  self                     = babl_calloc (sizeof (BablPixelFormat), 1);
+
+  self->instance.type = BABL_PIXEL_FORMAT;
+  self->instance.id   = id;
+  self->instance.name = babl_strdup (name);
+
+  self->bands         = bands;
+  self->planar        = planar;
+
+  self->component     = babl_malloc (sizeof (BablComponent*) * (bands+1));
+  self->type          = babl_malloc (sizeof (BablType*)      * (bands+1));
+  self->sampling      = babl_malloc (sizeof (BablSampling*)  * (bands+1));
+
+  for (band=0; band < bands; band++)
+    {
+      self->component[band] = band_component[band];
+      self->type[band] = band_type[band];
+      self->sampling[band] = band_sampling[band];
+    }
+  self->component[band] = NULL;
+  self->type[band]      = NULL;
+  self->sampling[band]  = NULL;
+
+  return self;
+}
+
+BablPixelFormat *
+babl_pixel_format_new (const char *name,
+                       ...)
+{
+  va_list varg;
+  BablPixelFormat *self;
+  int              id     = 0;
+  int              planar = 0;
+  int              bands  = 0;
+  BablComponent   *band_component [BABL_MAX_BANDS];
+  BablSampling    *band_sampling  [BABL_MAX_BANDS];
+  BablType        *band_type      [BABL_MAX_BANDS];
+
+  BablSampling    *current_sampling = babl_sampling (1,1);
+  BablType        *current_type     = babl_type_id (BABL_U8);
+  const char      *arg=name;
+
+  va_start (varg, name);
+
+  
+  while (1)
+    {
+      arg = va_arg (varg, char *);
+      if (!arg)
+        break;
+
+
+      if (BABL_IS_BABL (arg))
+        {
+          Babl *babl = (Babl*)arg;
+
+          switch (BABL_INSTANCE_TYPE (arg))
+            {
+              case BABL_TYPE:
+                current_type = (BablType*) babl;
+                break;
+              case BABL_COMPONENT:
+                band_component [bands] = (BablComponent*) babl;
+                band_type      [bands] = current_type;
+                band_sampling  [bands] = current_sampling;
+                bands++;
+
+                if (bands>=BABL_MAX_BANDS)
+                  {
+                    babl_log ("maximum number of bands (%i) exceeded for %s",
+                              BABL_MAX_BANDS, name);
+                  }
+                break;
+              case BABL_SAMPLING:
+                  current_sampling = (BablSampling*)arg;
+                  break;
+              case BABL_INSTANCE:
+              case BABL_MODEL:
+                babl_log ("%s(): %s not handled in pixel format yet",
+                          __FUNCTION__, babl_class_name (babl->instance.type));
+                  break;
+              case BABL_PIXEL_FORMAT:
+
+              case BABL_CONVERSION:
+              case BABL_CONVERSION_TYPE:
+              case BABL_CONVERSION_TYPE_PLANAR:
+              case BABL_CONVERSION_MODEL_PLANAR:
+              case BABL_CONVERSION_PIXEL_FORMAT:
+              case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
+              case BABL_FISH:
+                babl_log ("%s(): %s unexpected",
+                          __FUNCTION__, babl_class_name (babl->instance.type));
+                break;
+              case BABL_SKY: /* shut up compiler */
+                break;
+            }
+        }
+      /* if we didn't point to a babl, we assume arguments to be strings */
+      else if (!strcmp (arg, "id"))
+        {
+          id = va_arg (varg, int);
+        }
+      
+      else if (!strcmp (arg, "packed"))
+        {
+          planar = 0;
+        }
+      
+      else if (!strcmp (arg, "planar"))
+        {
+          planar = 1;
+        }
+      
+      else
+        {
+          babl_log ("%s: unhandled parameter '%s' for pixel_format '%s'",
+                    __FUNCTION__, arg, name);
+          exit (-1);
+        }
+    }
+    
+  va_end   (varg);
+
+
+  self =pixel_format_new (name, id,
+                          planar,
+                          bands, band_component, band_sampling, band_type);
+
+  
+  if ((BablPixelFormat*) db_insert ((Babl*)self) == self)
+    {
+      return self;
+    }
+  else
+    {
+      each_babl_pixel_format_destroy ((Babl*)self, NULL);
+      return NULL;
+    }
+}
+
+BABL_CLASS_TEMPLATE (BablPixelFormat, babl_pixel_format, "BablPixelFormat")
diff --git a/babl/babl-pixel-format.h b/babl/babl-pixel-format.h
new file mode 100644 (file)
index 0000000..a9d7977
--- /dev/null
@@ -0,0 +1,26 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_PIXEL_FORMAT_H
+#define _BABL_PIXEL_FORMAT_H
+
+#include "babl-classes.h"
+BABL_DEFINE_CLASS(BablPixelFormat, babl_pixel_format)
+
+#endif
diff --git a/babl/babl-sampling.c b/babl/babl-sampling.c
new file mode 100644 (file)
index 0000000..567f0c6
--- /dev/null
@@ -0,0 +1,94 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#define HORIZONTAL_MIN 1
+#define HORIZONTAL_MAX 4
+#define VERTICAL_MIN   1
+#define VERTICAL_MAX   4
+
+#include "babl-internal.h"
+
+static BablSampling db[(HORIZONTAL_MAX-HORIZONTAL_MIN+1)*
+                       (VERTICAL_MAX-VERTICAL_MIN+1)];
+
+BablSampling *
+babl_sampling (int horizontal,
+               int vertical)
+{
+  if (vertical>=1 &&
+      vertical<=4 &&
+      horizontal>=1 &&
+      horizontal<=4)
+    return &db [ (vertical-1) * 4 + (horizontal-1)];
+  else
+    babl_log ("babl_samping(%i,%i): parameters out of bounds",
+              horizontal, vertical);
+  return NULL;
+}
+
+
+static int 
+each_babl_sampling_destroy (Babl *babl,
+                            void *data)
+{
+  babl_free (babl->sampling.from);
+  babl_free (babl->sampling.to);
+  return 0;  /* continue iterating */
+}
+
+void
+babl_sampling_each (BablEachFunction  each_fun,
+                    void             *user_data)
+{
+  int horizontal;
+  int vertical;
+
+  for (horizontal=HORIZONTAL_MIN; horizontal<=HORIZONTAL_MAX; horizontal++)
+    for (vertical=VERTICAL_MIN; vertical<=VERTICAL_MAX; vertical++)
+      {
+       int index= (vertical-VERTICAL_MIN) * VERTICAL_MAX + (horizontal - HORIZONTAL_MIN);
+       if (each_fun ((Babl*) &(db[index]), user_data))
+         return;
+      }
+}
+
+
+void
+babl_sampling_destroy (void)
+{
+  babl_sampling_each (each_babl_sampling_destroy, NULL);
+}
+
+void
+babl_sampling_init (void)
+{
+  int horizontal;
+  int vertical;
+
+  for (horizontal=HORIZONTAL_MIN; horizontal<=HORIZONTAL_MAX; horizontal++)
+    for (vertical=VERTICAL_MIN; vertical<=VERTICAL_MAX; vertical++)
+      {
+        int index= (vertical-VERTICAL_MIN) * VERTICAL_MAX + (horizontal - HORIZONTAL_MIN);
+        db[index].instance.type = BABL_SAMPLING;
+        db[index].instance.id = 0;
+        db[index].instance.name = "Samplings have no name";
+        db[index].horizontal = horizontal;
+        db[index].vertical   = vertical;
+      }
+}
diff --git a/babl/babl-sampling.h b/babl/babl-sampling.h
new file mode 100644 (file)
index 0000000..12ec5c9
--- /dev/null
@@ -0,0 +1,32 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_SAMPLING_H
+#define _BABL_SAMPLING_H
+
+#include "babl-classes.h"
+
+void           babl_sampling_init       (void);
+void           babl_sampling_introspect (void);
+void           babl_sampling_each       (BablEachFunction  each_fun,
+                                         void             *user_data);
+void           babl_sampling_destroy    (void);    
+BablSampling * babl_sampling            (int horizontal,
+                                         int vertical);
+#endif
diff --git a/babl/babl-sanity.c b/babl/babl-sanity.c
new file mode 100644 (file)
index 0000000..4075bda
--- /dev/null
@@ -0,0 +1,180 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl.h"
+#include "babl-internal.h"
+static int
+foo (Babl *babl,
+     void *user_data)
+{
+/*  babl_log ("%s", babl->instance.name);*/
+  return 0;
+}
+
+static Babl *babl_conversion_source      (Babl *babl);
+static Babl *babl_conversion_destination (Babl *babl);
+
+static int
+type_sanity (Babl *babl,
+             void *user_data)
+{
+  /* ensure that every type has reference conversions to
+   * and from double */
+  void **ptr;
+  int  ok;
+
+  ok = 0;
+  if (babl->type.from)
+    {
+      ptr = (void **) babl->type.from;
+
+      while (ptr && NULL!=*ptr)
+        {
+          if (babl_conversion_destination ((Babl *)(*ptr)) == (Babl*)babl_type_id (BABL_DOUBLE))
+            {
+              ok = 1;
+              break;
+            }
+          ptr++;
+        }
+    }
+  if (!ok)
+    babl_log ("lack of sanity! type '%s' has no conversion to double",
+      babl->instance.name);
+
+
+  ok = 0;
+  if (babl->type.to)
+    {
+      ptr = (void **) babl->type.to;
+
+      while (ptr && NULL!=*ptr)
+        {
+          if (babl_conversion_source ((Babl *)(*ptr)) == (Babl*)babl_type_id (BABL_DOUBLE))
+            {
+              ok = 1;
+              break;
+            }
+          ptr++;
+        }
+    }
+  if (!ok)
+    babl_log ("lack of sanity! type '%s' has no conversion from double",
+      babl->instance.name);
+
+  return 0;
+}
+
+
+static int
+model_sanity (Babl *babl,
+              void *user_data)
+{
+  /* ensure that every type has reference conversions to
+   * and from rgba */
+  void **ptr;
+  int  ok;
+
+  ok = 0;
+  if (babl->model.from)
+    {
+      ptr = (void **) babl->model.from;
+
+      while (ptr && NULL!=*ptr)
+        {
+          if (babl_conversion_destination ((Babl *)(*ptr)) == (Babl*)babl_model_id (BABL_RGBA))
+            {
+              ok = 1;
+              break;
+            }
+          ptr++;
+        }
+    }
+  if (!ok)
+    babl_log ("lack of sanity! model '%s' has no conversion to 'rgba'",
+      babl->instance.name);
+
+
+  ok = 0;
+  if (babl->model.to)
+    {
+      ptr = (void **) babl->model.to;
+
+      while (ptr && NULL!=*ptr)
+        {
+          if (babl_conversion_source ((Babl *)(*ptr)) == (Babl*)babl_model_id (BABL_RGBA))
+            {
+              ok = 1;
+              break;
+            }
+          ptr++;
+        }
+    }
+  if (!ok)
+    babl_log ("lack of sanity! model '%s' has no conversion from 'rgba'",
+      babl->instance.name);
+
+  return 0;
+}
+
+static int
+id_sanity (Babl *babl,
+           void *user_data)
+{
+  if (0 == babl->instance.id)
+    {
+      babl_log ("%s\t'%s' has id==0",
+        babl_class_name (babl->instance.type), babl->instance.name);
+    }
+  return 0;
+}
+
+void
+babl_sanity (void)
+{
+  babl_type_each         (id_sanity, NULL);
+  babl_component_each    (id_sanity, NULL);
+  babl_model_each        (id_sanity, NULL);
+  babl_pixel_format_each (id_sanity, NULL);
+
+  babl_type_each         (type_sanity, NULL);
+  babl_sampling_each     (foo, NULL);
+  babl_component_each    (foo, NULL);
+  babl_model_each        (model_sanity, NULL);
+  babl_pixel_format_each (foo, NULL);
+  babl_conversion_each   (foo, NULL);
+
+
+
+}
+
+
+
+/* FIXME: these should be moved to babl-conversion.c */
+
+static Babl *babl_conversion_source      (Babl *babl)
+{
+  return (Babl *)babl->conversion.source;
+}
+
+static Babl *babl_conversion_destination (Babl *babl)
+{
+  return (Babl *)babl->conversion.destination;
+}
diff --git a/babl/babl-sanity.h b/babl/babl-sanity.h
new file mode 100644 (file)
index 0000000..0f41067
--- /dev/null
@@ -0,0 +1,25 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_SANITY_H
+#define _BABL_SANITY_H
+
+void babl_sanity (void);
+
+#endif
diff --git a/babl/babl-type.c b/babl/babl-type.c
new file mode 100644 (file)
index 0000000..ba1ff8e
--- /dev/null
@@ -0,0 +1,135 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl-internal.h"
+#include "babl-db.h"
+
+
+#include <string.h>
+#include <stdarg.h>
+
+static int 
+each_babl_type_destroy (Babl *babl,
+                        void *data)
+{
+  babl_free (babl->instance.name);
+  babl_free (babl->type.from);
+  babl_free (babl->type.to);
+  babl_free (babl);
+  return 0;  /* continue iterating */
+}
+
+
+static BablType *
+type_new (const char  *name,
+          int          id,
+          int          bits)
+{
+  BablType *self;
+
+  self                = babl_calloc (sizeof (BablType), 1);
+  self->instance.type = BABL_TYPE;
+  self->instance.id   = id;
+  self->instance.name = babl_strdup (name);
+  self->bits          = bits;
+
+  return self;
+}
+
+BablType *
+babl_type_new (const char *name,
+               ...)
+{
+  va_list      varg;
+  BablType    *self;
+  int          id          = 0;
+  int          bits        = 0;
+
+  const char *arg=name;
+
+  va_start (varg, name);
+  
+  while (1)
+    {
+      arg = va_arg (varg, char *);
+      if (!arg)
+        break;
+     
+      if (BABL_IS_BABL (arg))
+        {
+          Babl *babl = (Babl*)arg;
+
+          switch (BABL_INSTANCE_TYPE (arg))
+            {
+              case BABL_TYPE:
+              case BABL_INSTANCE:
+              case BABL_COMPONENT:
+              case BABL_MODEL:
+              case BABL_PIXEL_FORMAT:
+              case BABL_SAMPLING:
+
+              case BABL_CONVERSION:
+              case BABL_CONVERSION_TYPE:
+              case BABL_CONVERSION_TYPE_PLANAR:
+              case BABL_CONVERSION_MODEL_PLANAR:
+              case BABL_CONVERSION_PIXEL_FORMAT:
+              case BABL_CONVERSION_PIXEL_FORMAT_PLANAR:
+              case BABL_FISH:
+                babl_log ("%s(): %s unexpected",
+                          __FUNCTION__, babl_class_name (babl->instance.type));
+                break;
+              case BABL_SKY: /* shut up compiler */
+                break;
+            }
+        }
+      /* if we didn't point to a babl, we assume arguments to be strings */
+      else if (!strcmp (arg, "id"))
+        {
+          id = va_arg (varg, int);
+        }
+      
+      else if (!strcmp (arg, "bits"))
+        {
+          bits = va_arg (varg, int);
+        }
+      
+      else
+        {
+          babl_log ("%s(): unhandled parameter '%s' for pixel_format '%s'",
+                    __FUNCTION__, arg, name);
+          exit (-1);
+        }
+    }
+    
+  va_end   (varg);
+
+  self = type_new (name, id, bits);
+
+  if ((BablType*) db_insert ((Babl*)self) == self)
+    {
+      return self;
+    }
+  else
+    {
+      each_babl_type_destroy ((Babl*)self, NULL);
+      return NULL;
+    }
+}
+
+BABL_CLASS_TEMPLATE (BablType, babl_type, "BablType")
diff --git a/babl/babl-type.h b/babl/babl-type.h
new file mode 100644 (file)
index 0000000..6b05fe8
--- /dev/null
@@ -0,0 +1,26 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_TYPE_H
+#define _BABL_TYPE_H
+
+#include "babl-classes.h"
+BABL_DEFINE_CLASS(BablType, babl_type)
+
+#endif
diff --git a/babl/babl-util.c b/babl/babl-util.c
new file mode 100644 (file)
index 0000000..14ceba1
--- /dev/null
@@ -0,0 +1,61 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "babl-memory.h"
+
+static int list_length (void **list)
+{
+  void **ptr;
+  int    len=0;
+  
+  ptr = list;
+  while (NULL!=*ptr)
+    {
+      ptr++;
+      len++;
+    }
+  return len;
+}
+
+void
+babl_add_ptr_to_list (void ***list,
+                      void   *new)
+{
+  int orig_len=0;
+  if (*list)
+    {
+      orig_len = list_length (*list);
+    }
+
+  *list = babl_realloc ( (*list), 
+                          sizeof(void *) * (orig_len + 2));
+
+  if (!(*list))
+    {
+      fprintf (stderr, "%s(): eeek! failed to realloc", __FUNCTION__);
+    }
+
+  (*list)[orig_len]=new;
+  (*list)[orig_len+1]=NULL;
+}
+
diff --git a/babl/babl-util.h b/babl/babl-util.h
new file mode 100644 (file)
index 0000000..97b0816
--- /dev/null
@@ -0,0 +1,26 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_UTIL_H
+#define _BABL_UTIL_H
+
+void   babl_add_ptr_to_list (void       ***list,
+                             void         *new);
+
+#endif
diff --git a/babl/babl.c b/babl/babl.c
new file mode 100644 (file)
index 0000000..ab3e96f
--- /dev/null
@@ -0,0 +1,53 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl.h"
+#include "babl-internal.h"
+#include "babl-base.h"
+#include "babl-sanity.h"
+#include "babl-introspect.h"
+
+void
+babl_init (void)
+{
+  babl_type_init ();
+  babl_sampling_init ();
+  babl_component_init ();
+  babl_model_init ();
+  babl_pixel_format_init ();
+  babl_conversion_init ();
+  babl_base_init ();
+
+  babl_sanity ();
+}
+
+void
+babl_destroy (void)
+{
+  /* babl_base is destroy by the containing types */
+
+  babl_conversion_destroy ();
+  babl_pixel_format_destroy ();
+  babl_model_destroy ();
+  babl_component_destroy ();
+  babl_sampling_destroy ();
+  babl_type_destroy ();
+
+  babl_memory_sanity ();
+}
diff --git a/babl/babl.h b/babl/babl.h
new file mode 100644 (file)
index 0000000..4ac555a
--- /dev/null
@@ -0,0 +1,46 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _BABL_H
+#define _BABL_H
+
+#if __GNUC__ >=4
+   #define BABL_NULL_TERMINATED __attribute_((__sentinel__))
+#else
+   #define BABL_NULL_TERMINATED
+#endif
+
+#include <stdlib.h>
+#include "babl-classes.h"
+#include "babl-conversion.h"
+#include "babl-fish.h"
+#include "babl-model.h"
+#include "babl-ids.h"
+#include "babl-type.h"
+#include "babl-component.h"
+#include "babl-sampling.h"
+#include "babl-pixel-format.h"
+
+
+void babl_init       (void);
+void babl_sanity     (void);
+void babl_introspect (void);
+void babl_destroy    (void);
+
+#endif
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..126a9cc
--- /dev/null
@@ -0,0 +1,40 @@
+AC_INIT(babl/babl.h)
+AM_CONFIG_HEADER(config.h)
+
+BABL_MAJOR_VERSION=0
+BABL_MINOR_VERSION=0
+BABL_MICRO_VERSION=1
+
+BABL_API_VERSION=0.0
+AC_SUBST(BABL_API_VERSION)
+
+BABL_LIBRARY_VERSION=0:0:0
+
+AC_SUBST(BABL_LIBRARY_VERSION)
+
+PACKAGE=babl
+
+BABL_VERSION=$BABL_MAJOR_VERSION.$BABL_MINOR_VERSION.$BABL_MICRO_VERSION
+BABL_RELEASE=$BABL_MAJOR_VERSION.$BABL_MINOR_VERSION
+AC_SUBST(BABL_RELEASE)
+AC_SUBST(BABL_VERSION)
+
+VERSION=$BABL_VERSION
+
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
+
+AC_PROG_CC
+AM_PROG_LIBTOOL
+AC_STDC_HEADERS
+AM_SANITY_CHECK
+
+dnl ===========================================================================
+
+AC_OUTPUT(Makefile                            \
+          babl.pc                             \
+          babl/Makefile                       \
+          babl/babl-base/Makefile             \
+          tests/Makefile                      \
+          INSTALL                             \
+          README
+)
diff --git a/depcomp b/depcomp
new file mode 100755 (executable)
index 0000000..04701da
--- /dev/null
+++ b/depcomp
@@ -0,0 +1,530 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2005-07-09.11
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> $depfile
+    echo >> $depfile
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> $depfile
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
+  tmpdepfile="$stripped.u"
+  if test "$libtool" = yes; then
+    "$@" -Wc,-M
+  else
+    "$@" -M
+  fi
+  stat=$?
+
+  if test -f "$tmpdepfile"; then :
+  else
+    stripped=`echo "$stripped" | sed 's,^.*/,,'`
+    tmpdepfile="$stripped.u"
+  fi
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+
+  if test -f "$tmpdepfile"; then
+    outname="$stripped.o"
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
+    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mecanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space in the [].
+      sed -e 's,^.*\.[a-z]*:[   ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $dashmflag |
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no
+  for arg in "$@"; do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix="`echo $object | sed 's/^.*\././'`"
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o,
+  # because we must use -o when running libtool.
+  "$@" || exit $?
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+       set fnord "$@"
+       shift
+       shift
+       ;;
+    *)
+       set fnord "$@" "$arg"
+       shift
+       shift
+       ;;
+    esac
+  done
+  "$@" -E |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::   \1 \\:p' >> "$depfile"
+  echo "       " >> "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/install-sh b/install-sh
new file mode 100755 (executable)
index 0000000..4d4a951
--- /dev/null
@@ -0,0 +1,323 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2005-05-14.22
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+chmodcmd="$chmodprog 0755"
+chowncmd=
+chgrpcmd=
+stripcmd=
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=
+dst=
+dir_arg=
+dstarg=
+no_target_directory=
+
+usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+-c         (ignored)
+-d         create directories instead of installing files.
+-g GROUP   $chgrpprog installed files to GROUP.
+-m MODE    $chmodprog installed files to MODE.
+-o USER    $chownprog installed files to USER.
+-s         $stripprog installed files.
+-t DIRECTORY  install into DIRECTORY.
+-T         report an error if DSTFILE is a directory.
+--help     display this help and exit.
+--version  display version info and exit.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
+"
+
+while test -n "$1"; do
+  case $1 in
+    -c) shift
+        continue;;
+
+    -d) dir_arg=true
+        shift
+        continue;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+        shift
+        shift
+        continue;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) chmodcmd="$chmodprog $2"
+        shift
+        shift
+        continue;;
+
+    -o) chowncmd="$chownprog $2"
+        shift
+        shift
+        continue;;
+
+    -s) stripcmd=$stripprog
+        shift
+        continue;;
+
+    -t) dstarg=$2
+       shift
+       shift
+       continue;;
+
+    -T) no_target_directory=true
+       shift
+       continue;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    *)  # When -d is used, all remaining arguments are directories to create.
+       # When -t is used, the destination is already specified.
+       test -n "$dir_arg$dstarg" && break
+        # Otherwise, the last argument is the destination.  Remove it from $@.
+       for arg
+       do
+          if test -n "$dstarg"; then
+           # $@ is not empty: it contains at least $arg.
+           set fnord "$@" "$dstarg"
+           shift # fnord
+         fi
+         shift # arg
+         dstarg=$arg
+       done
+       break;;
+  esac
+done
+
+if test -z "$1"; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src ;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    src=
+
+    if test -d "$dst"; then
+      mkdircmd=:
+      chmodcmd=
+    else
+      mkdircmd=$mkdirprog
+    fi
+  else
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dstarg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dstarg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst ;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+       echo "$0: $dstarg: Is a directory" >&2
+       exit 1
+      fi
+      dst=$dst/`basename "$src"`
+    fi
+  fi
+
+  # This sed command emulates the dirname command.
+  dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
+
+  # Make sure that the destination directory exists.
+
+  # Skip lots of stat calls in the usual case.
+  if test ! -d "$dstdir"; then
+    defaultIFS='
+        '
+    IFS="${IFS-$defaultIFS}"
+
+    oIFS=$IFS
+    # Some sh's can't handle IFS=/ for some reason.
+    IFS='%'
+    set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+    shift
+    IFS=$oIFS
+
+    pathcomp=
+
+    while test $# -ne 0 ; do
+      pathcomp=$pathcomp$1
+      shift
+      if test ! -d "$pathcomp"; then
+        $mkdirprog "$pathcomp"
+       # mkdir can fail with a `File exist' error in case several
+       # install-sh are creating the directory concurrently.  This
+       # is OK.
+       test -d "$pathcomp" || exit
+      fi
+      pathcomp=$pathcomp/
+    done
+  fi
+
+  if test -n "$dir_arg"; then
+    $doit $mkdircmd "$dst" \
+      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
+      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
+      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
+      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
+
+  else
+    dstfile=`basename "$dst"`
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+    trap '(exit $?); exit' 1 2 13 15
+
+    # Copy the file name to the temp name.
+    $doit $cpprog "$src" "$dsttmp" &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
+      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
+      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
+      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
+
+    # Now rename the file to the real destination.
+    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
+      || {
+          # The rename failed, perhaps because mv can't rename something else
+          # to itself, or perhaps because mv is so ancient that it does not
+          # support -f.
+
+          # Now remove or move aside any old file at destination location.
+          # We try this two ways since rm can't unlink itself on some
+          # systems and the destination file might be busy for other
+          # reasons.  In this case, the final cleanup might fail but the new
+          # file should still install successfully.
+          {
+            if test -f "$dstdir/$dstfile"; then
+              $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
+              || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
+              || {
+                echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+                (exit 1); exit 1
+              }
+            else
+              :
+            fi
+          } &&
+
+          # Now rename the file to the real destination.
+          $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+        }
+    }
+  fi || { (exit 1); exit 1; }
+done
+
+# The final little trick to "correctly" pass the exit status to the exit trap.
+{
+  (exit 0); exit 0
+}
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/missing b/missing
new file mode 100755 (executable)
index 0000000..894e786
--- /dev/null
+++ b/missing
@@ -0,0 +1,360 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2005-06-08.21
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
+#   Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case "$1" in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).
+case "$1" in
+  lex|yacc)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case "$1" in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case "$f" in
+      *:*) touch_files="$touch_files "`echo "$f" |
+                                      sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+          sed 's/\.am$/.in/' |
+          while read f; do touch "$f"; done
+    ;;
+
+  autom4te)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+    if test -f "$file"; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo "#! /bin/sh"
+       echo "# Created by GNU Automake missing as a replacement of"
+       echo "#  $ $@"
+       echo "exit 0"
+       chmod +x $file
+       exit 1
+    fi
+    ;;
+
+  bison|yacc)
+    echo 1>&2 "\
+WARNING: \`$1' $msg.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+       case "$LASTARG" in
+       *.y)
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" y.tab.c
+           fi
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" y.tab.h
+           fi
+         ;;
+       esac
+    fi
+    if [ ! -f y.tab.h ]; then
+       echo >y.tab.h
+    fi
+    if [ ! -f y.tab.c ]; then
+       echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+       case "$LASTARG" in
+       *.l)
+           SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" lex.yy.c
+           fi
+         ;;
+       esac
+    fi
+    if [ ! -f lex.yy.c ]; then
+       echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+        you modified a dependency of a manual page.  You may need the
+        \`Help2man' package in order for those modifications to take
+        effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+       file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+    fi
+    if [ -f "$file" ]; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo ".ab help2man is required to generate this page"
+       exit 1
+    fi
+    ;;
+
+  makeinfo)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar)
+    shift
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+       case "$firstarg" in
+       *o*)
+           firstarg=`echo "$firstarg" | sed s/o//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+       case "$firstarg" in
+       *h*)
+           firstarg=`echo "$firstarg" | sed s/h//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequisites for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/tests/.cvsignore b/tests/.cvsignore
new file mode 100644 (file)
index 0000000..7d0280e
--- /dev/null
@@ -0,0 +1,5 @@
+Makefile
+Makefile.in
+nop
+introspect
+
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644 (file)
index 0000000..3be1ce5
--- /dev/null
@@ -0,0 +1,16 @@
+noinst_PROGRAMS =      \
+       introspect      \
+       nop
+AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
+
+introspect_SOURCES = \
+       introspect.c
+introspect_LDADD = $(top_builddir)/babl/libbabl.la
+
+nop_SOURCES = \
+       nop.c
+nop_LDADD = $(top_builddir)/babl/libbabl.la
+
+EXTRA_DIST=            \
+       .cvsignore
diff --git a/tests/introspect.c b/tests/introspect.c
new file mode 100644 (file)
index 0000000..6712c21
--- /dev/null
@@ -0,0 +1,31 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl.h"
+#include "babl-internal.h"
+
+int
+main (int    argc,
+      char **argv)
+{
+  babl_init ();
+  babl_introspect ();
+  babl_destroy ();
+  return 0;
+}
diff --git a/tests/nop.c b/tests/nop.c
new file mode 100644 (file)
index 0000000..bdf6fde
--- /dev/null
@@ -0,0 +1,30 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "babl.h"
+#include "babl-internal.h"
+
+int
+main (int    argc,
+      char **argv)
+{
+  babl_init ();
+  babl_destroy ();
+  return 0;
+}